package org.yinxianren.scala.test

class Myclass {

}

class Time{

  var hour = 12;
  var minute = 5;
  var celsius : Float = _

}


class Keyed{
  def computeKey ={
    0
  }
}

class MemoKeyed extends  Keyed {
  private var keyCache : Option[Int] = None;
  override def computeKey: Int = {
    if (!keyCache.isDefined)   keyCache = Some(super.computeKey)
    keyCache.get
  }
}


class BankAccount{

  private var bal = 0;
  def balance = bal;

  def deposit( amount : Int ) = {
    require( amount > 0)
    bal += amount
    bal;
  }

  def withdraw( amount : Int) = {
    if (amount > bal) false;
    else {
      bal -=amount;
      true;
    }
  }
}